using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SecurityLinkUp
{
    public partial class Register : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void RegisterBtn_Click(object sender, EventArgs e)
        {
            // check to make sure that password and confirm password matches
            if (Password.Text != ConfirmPassword.Text)
            {
                ErrorMessage.Text = "Passwords do not match";
                return;
            }

            // try to create the user
            MembershipCreateStatus status;
            MembershipUser usr = Membership.CreateUser(Username.Text, Password.Text, Email.Text, SecurityQuestion.SelectedValue, SecurityAnswer.Text, true, out status);
            if (status != MembershipCreateStatus.Success)
            {
                ErrorMessage.Text = status.ToString();
                return;
            }

            // log that we have created the user
            Log.LogRegisteredUser(Username.Text);

            // User has been created OK - transfer  to the confirmation page
            // to trigger the redirect countdown
            Response.Redirect("/RegComplete.aspx", true);
        }

    }
}
